<?

include_once "accesscontrol.php";

$day = date(d);
$month = date(m);
$year = date(Y);
$del = "delete from job_post where EXday = \"$day\" and EXmonth = \"$month\" and EXyear = \"$year\" ";
$rdel = mysql_query($del) or die(mysql_error());
$s_age = explode("-", $_POST[age]);
$f_age = $s_age[0];
$l_age = $s_age[1];

$q4 = "update job_employer_info set JS_number = JS_number - '1' where ename = \"$_SESSION[ename]\" ";
$r4 = mysql_query($q4) or die(mysql_error());

if(!empty($_POST))
{
	extract($_POST);
}

if(!empty($_GET))
{
	extract($_GET);
}

$sch = array(); 
if (!empty($JobCategory)) 
{
	$sch[] = "job_category like '%$JobCategory%'";
}
if (!empty($careerlevel)) 
{
	$sch[] = "careerlevel = \"$careerlevel\" ";
}
if (!empty($target_company)) 
{
	$sch[] = "target_company = \"$target_company\" ";
}
if (!empty($relocate)) 
{
	$sch[] = "relocate = \"$relocate\" ";
}
if (!empty($country)) 
{
	$sch[] = "country = \"$country\" ";
}
if (!empty($city)) 
{
	$sch[] = "city like '%$city%'";
}
if (!empty($state)) 
{
	$sch[] = "state = \"$state\" ";
}

if(!empty($nationality))
{
	$sch[] = "nationality = \"$nationality\" ";
}

if(!empty($sex))
{
	$sch[] = "sex = \"$sex\" ";
}

if(!empty($income))
{
	$sch[] = "income = \"$income\" ";
}

if(!empty($maritalstatus))
{
	$sch[] = "maritalstatus = \"$maritalstatus\" ";
}

if(!empty($age))
{
	$ny = date(Y);

	$sch[] = " age between '$f_age' and '$l_age' ";
}

if (!empty($kw)) 
{
	$sch[] = "rTitle like '%$kw%' or rPar like '%$kw%' ";
}

if (!$ByPage) $ByPage=5;  
if (!$Start) $Start=0; 

if($sm == 'or')
{
	$qs = "select * from job_seeker_info ".(($sch)?"where ".join(" or ", $sch):"")." limit $Start,$ByPage";
	$qss = "select * from job_seeker_info ".(($sch)?"where ".join(" or ", $sch):"");
}
elseif($sm == 'and')
{
	$qs = "select * from job_seeker_info ".(($sch)?"where ".join(" and ", $sch):"")." limit $Start,$ByPage";
	$qss = "select * from job_seeker_info ".(($sch)?"where ".join(" and ", $sch):"");
}
$rqs = mysql_query($qs) or die(mysql_error());

$rqss = mysql_query($qss) or die(mysql_error());
$rr = mysql_num_rows($rqss);



echo "<table align=center><tr><td align=center>";
if($rr == '0')
{
	echo "<br><br><span class=TNA> No results found.</span>";
}
elseif($rr == '1')
{
	echo "<br><br><span class=HeaderClass> Your search return one result. </span>";
}
elseif($rr > '1')
{
	echo "<br><br><span class=HeaderClass>Your search return $rr results. </span>";
}
while($as = mysql_fetch_array($rqs))
{

$cl = career_level("", $as[careerlevel]);

	echo "<br><table align=center width=460 cellspacing=0 border=1 bordercolor=black class=BlackText>
		<tr>
		<td>Name:</td><td bgcolor=dddddd><a class=TNA href=\"EmployerView.php?uname=$as[uname]\"> $as[fname] $as[lname] </a></td>
		</tr>

		<tr><td>Career level: </td>
		<td bgcolor=dddddd> $cl</td></tr>
		<tr>
		<td width=100 valign=top>Prefered jobs:</td>
		<td bgcolor=dddddd>
		$as[job_category] 
		</td>
		</tr>
		</table>
		";
}


if($sm == 'or')
{
$qs2 = "select * from job_seeker_info ".(($sch)?"where ".join(" or ", $sch):"");
}
elseif($sm == 'and')
{
$qs2 = "select * from job_seeker_info ".(($sch)?"where ".join(" and ", $sch):"");
}
$rqs2 = mysql_query($qs2) or die(mysql_error());
$rr2 = mysql_num_rows($rqs2);

echo "<table align=center width=460><tr>";


	if ($rr2 <= $ByPage && $Start == '0')
	{

	}

	if ( $Start > 0 )
	{
		$nom1 = $Start - $ByPage;
		echo "<td align=left><a class=TNA href=\"Search2.php?sm=$sm&JobCategory=$JobCategory&careerlevel=$careerlevel&target_company=$target_company&relocate=$relocate&country=$country&city=$city&kw=$kw&Start=$nom1&nationality=$nationality&sex=$sex&income=$income&maritalstatus=$maritalstatus&age=$age\">previous</a></td>";
	}

	if ($rr2 > $Start + $ByPage  || ($Start == 0 && $rr2 > $ByPage))
	{
		$nom = $Start + $ByPage;
		echo "<td align=right><a class=TNA href=\"Search2.php?sm=$sm&JobCategory=$JobCategory&careerlevel=$careerlevel&target_company=$target_company&relocate=$relocate&country=$country&city=$city&kw=$kw&Start=$nom&nationality=$nationality&sex=$sex&income=$income&maritalstatus=$maritalstatus&age=$age\">next</a></td>";
	}

echo "</tr></table>";

echo "</td></tr></table>";



?>

<? include_once('../footer.php'); ?>